<?php


namespace app\common\model;


class RoomUser extends BaseModel{

    protected $createTime = false;
    protected $updateTime = false;

    public function user(){
        return $this->belongsTo('User','user_id','id')->field('id,nickname,avatar,education');
    }

    public static function getUserIds($roomId){
        return self::where('room_id',$roomId)->column('user_id');
    }

    public static function getRoomIdByTypes($userId,$types){
        return self::where('user_id',$userId)->where('types',$types)->value('room_id');
    }
}